<template>
  <div>
    <h2>当前时间为:{{ time }}</h2>
  </div>
</template>

<script>
import dayjs from "dayjs";

export default {
  name: "showTime",
  data() {
    return {
      time: undefined
    }
  },
  created() {
    this.init();
  },
  mounted() {
    setInterval(() => {
      this.init()
    }, 1000)
  },
  methods: {
    init() {
      this.time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
    }
  }
}
</script>

<style scoped>

</style>
